// localStorage的封装类
class LocalStorage {
    static localstorage: LocalStorage
    private constructor() {
    }

    public static getInstance() {
        if (!LocalStorage.localstorage) {
            LocalStorage.localstorage = new LocalStorage()
        }
        return LocalStorage.localstorage
    }
    public getItem(key: string) {
        let value = localStorage.getItem(key)
        return value ? JSON.parse(value) : null
    }

    public setItem(key: string, value: any) {
        localStorage.setItem(key, JSON.stringify(value))
    }

    public removeItem(key: string) {
        localStorage.removeItem(key)
    }
}

export default LocalStorage;
